<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="1000px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="180px">
          <el-form-item label="胸腺手术史">
            <el-radio-group v-model="form.bloodSpecimen">
              <el-radio :label="1">无</el-radio>
              <el-radio :label="2">有</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-collapse-transition>
            <div v-show="form.bloodSpecimen===2">
              <el-form-item label="胸腺手术时间">
                <el-date-picker v-model="form.thymicSurgeryTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="与首发症状的时间间隔">
                <el-input v-model="form.timeInterval" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="术前肌无力危象">
                <el-radio-group v-model="form.myastheniaCrisis">
                  <el-radio :label="1">无</el-radio>
                  <el-radio :label="2">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="查看重症肌无力危象定义" />
              <el-form-item label="术前MGFA分型（术前1周）">
                <el-select v-model="form.mgfa" placeholder="请选择">
                  <el-option
                    v-for="item in mgfa"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="有无球部肌肉受累">
                <el-radio-group v-model="form.ballMuscleInvolvement">
                  <el-radio :label="1">无</el-radio>
                  <el-radio :label="2">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="术前用药（1月内）">
                <el-radio-group v-model="form.preoperativeMedication">
                  <el-radio :label="1">无</el-radio>
                  <el-radio :label="2">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="术前丙球冲击（1月内）">
                <el-radio-group v-model="form.cBallImpact">
                  <el-radio :label="1">无</el-radio>
                  <el-radio :label="2">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="术前激素冲击（1月内）">
                <el-radio-group v-model="form.hormonalShock">
                  <el-radio :label="1">无</el-radio>
                  <el-radio :label="2">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="术前血浆置换（1月内）">
                <el-radio-group v-model="form.plasmaExchange">
                  <el-radio :label="1">无</el-radio>
                  <el-radio :label="2">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="术前肺功">
                <el-radio-group v-model="form.pulmonaryFunction">
                  <el-radio :label="1">已做</el-radio>
                  <el-radio :label="2">未做</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="手术方式">
                <el-radio-group v-model="form.operationMode">
                  <el-radio :label="1">经胸骨正中</el-radio>
                  <el-radio :label="2">经颈部胸腺切除</el-radio>
                  <el-radio :label="3">经颈胸联合胸腺切除</el-radio>
                  <el-radio :label="4">胸腔镜</el-radio>
                  <el-radio :label="5">机器人</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="切除范围">
                <el-radio-group v-model="form.resectionRange">
                  <el-radio :label="1">单纯胸腺切除</el-radio>
                  <el-radio :label="2">扩大胸腺切除（肿瘤切除+脂肪清扫）</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="手术时长">
                <el-input v-model="form.operationDuration" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="术中失血量（ml）">
                <el-input v-model="form.intraoperativeBloodLoss" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="术后肌无力危象">
                <el-radio-group v-model="form.myastheniaCrisisAfter">
                  <el-radio :label="1">无</el-radio>
                  <el-radio :label="2">有</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="查看重症肌无力危象定义" />
              <el-form-item label="术后并发症">
                <el-select v-model="form.complication" placeholder="请选择">
                  <el-option
                    v-for="item in complication"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="术后病理">
                <el-select v-model="form.pathology" placeholder="请选择">
                  <el-option
                    v-for="item in pathology"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="图片">
                <el-input v-model="form.picture" style="width: 370px;" />
              </el-form-item>
            </div>
          </el-collapse-transition>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="ID" />
        <el-table-column prop="thymicSurgeryTime" label="胸腺手术时间" />
        <el-table-column prop="timeInterval" label="与首发症状的时间间隔" />
        <el-table-column prop="operationMode" label="手术方式" />
        <el-table-column prop="resectionRange" label="切除范围" />
        <el-table-column prop="operationDuration" label="手术时长" />
        <el-table-column v-if="checkPer(['admin','thymusOperationRecord:edit','thymusOperationRecord:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudThymusOperationRecord from '@/api/thymusOperationRecord'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import CollapseTransition from 'element-ui/lib/transitions/collapse-transition'
import Vue from 'vue'

Vue.component(CollapseTransition.name, CollapseTransition)

const defaultForm = { id: null, pId: '', thymicSurgeryHistory: null, thymicSurgeryTime: null, timeInterval: null, myastheniaCrisis: null, mgfa: null, ballMuscleInvolvement: null, preoperativeMedication: null, cBallImpact: null, hormonalShock: null, plasmaExchange: null, pulmonaryFunction: null, operationMode: null, resectionRange: null, operationDuration: null, intraoperativeBloodLoss: null, myastheniaCrisisAfter: null, complication: null, pathology: null, picture: null }
export default {
  name: 'ThymusOperationRecord',
  components: { pagination, crudOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '手术记录', url: 'api/thymusOperationRecord', query: { }, idField: 'id', sort: 'id,desc', crudMethod: { ...crudThymusOperationRecord }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'thymusOperationRecord:add'],
        edit: ['admin', 'thymusOperationRecord:edit'],
        del: ['admin', 'thymusOperationRecord:del']
      },
      rules: {
        pId: [
          { required: true, message: 'pID不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'pId', display_name: 'pID' }
      ],
      mgfa: [{
        value: '1',
        label: 'Ⅰ型'
      }, {
        value: '2',
        label: 'ⅡA型'
      }, {
        value: '3',
        label: 'ⅡB型'
      }, {
        value: '4',
        label: 'ⅢA型'
      }, {
        value: '5',
        label: 'ⅢB型'
      }, {
        value: '6',
        label: 'ⅣA型'
      }, {
        value: '7',
        label: 'ⅣB型'
      }, {
        value: '8',
        label: 'Ⅴ型'
      }],
      complication: [{
        value: '1',
        label: '肺部感染'
      }, {
        value: '2',
        label: '胸腔积液'
      }, {
        value: '3',
        label: '下肢静脉血栓'
      }, {
        value: '4',
        label: '肺栓塞'
      }, {
        value: '5',
        label: '纵隔炎'
      }, {
        value: '6',
        label: '声带麻痹'
      }],
      pathology: [{
        value: '1',
        label: '正常胸腺'
      }, {
        value: '2',
        label: '胸腺增生'
      }, {
        value: '3',
        label: '胸腺瘤'
      }, {
        value: '4',
        label: '胸腺囊肿'
      }, {
        value: '5',
        label: '脂肪瘤'
      }, {
        value: '6',
        label: '胸腺萎缩'
      }, {
        value: '7',
        label: '未退化胸腺'
      }, {
        value: '8',
        label: '其他'
      }],
      pId: this._routerRoot._route.query.id
    }
  },
  created() {
    defaultForm.pId = this.pId
    this.crud.query.pId = this.pId
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      this.crud.query.pId = this.pId
      return true
    }
  }
}
</script>

<style scoped>

</style>
